// GxAccountEventSink.cpp : implementation file
//

#include "stdafx.h"
#include "SpeedOrder.h"
#include "GxAccountEventSink.h"
#include "P2_i.c"
#include "AccountManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GxAccountEventSink

IMPLEMENT_DYNCREATE(GxAccountEventSink, CCmdTarget)

GxAccountEventSink::GxAccountEventSink()
{
	m_pAccountMgr = NULL;
	EnableAutomation();
}

GxAccountEventSink::~GxAccountEventSink()
{
}


void GxAccountEventSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.
	m_Cookie = 0;
	CCmdTarget::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(GxAccountEventSink, CCmdTarget)
	//{{AFX_MSG_MAP(GxAccountEventSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(GxAccountEventSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(GxAccountEventSink)
	DISP_FUNCTION(GxAccountEventSink, "OnAccountUpdated", OnAccountUpdated, VT_EMPTY, VTS_DISPATCH)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IGxAccountEventSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {28E6744A-4057-4CF2-8687-252E7E8769C4}
//static const IID IID_IGxAccountEventSink =
//{ 0x28e6744a, 0x4057, 0x4cf2, { 0x86, 0x87, 0x25, 0x2e, 0x7e, 0x87, 0x69, 0xc4 } };

BEGIN_INTERFACE_MAP(GxAccountEventSink, CCmdTarget)
	INTERFACE_PART(GxAccountEventSink, DIID_IGxAccountEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GxAccountEventSink message handlers

void GxAccountEventSink::OnAccountUpdated(LPDISPATCH a_GxAccount) 
{
	// TODO: Add your dispatch handler code here
	if (m_pAccountMgr)
		m_pAccountMgr->OnAccountUndated();
}
